Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@darkwolf/validator

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@darkwolf/validator

Validator Utility

  • 2.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

Validator Utility

Install

npm i --save @darkwolf/validator

Usage

const validator = require('@darkwolf/validator')

validator.isNumber(13) // true
validator.isString(21) // false

// Using constructor
const { Validator } = validator

new Validator(69).isString().isValid // false
new Validator(69).isNumber().isRange(0, 100).isValid // true
new Validator('69')
  .isNumber()
  .throw(() => new TypeError('Value must be a number')) // throw error

Init

new Validator(value?)

Methods

throw(() => e)

isRequired()

isOptional()

is(value => !!value)

isEqual(value1?, value2)

isStrictEqual(value1?, value2)

isType(value?, type)

isTag(value?, tag)

isInstance(value?, constructor)

isUndefined(value?)

isNull(value?)

isNil(value?)

isObject(value?)

isObjectLike(value?)

isPlainObject(value?)

isFunction(value?)

isBoolean(value?)

isNumber(value?)

isString(value?)

isSymbol(value?)

isArray(value?)

isBuffer(value?)

isArrayBuffer(value?)

isRegExp(value?)

isSet(value?)

isMap(value?)

isPromise(value?)

isDate(value?)

isError(value?)

isTypeError(value?)

isValidator(value?)

isCodeError(value?)

isNaN(value?)

isFinite(value?)

isInteger(value?)

isSafeInteger(value?)

isFloat(value?)

isDecimal(value?)

isInfinity(value?)

isMore(value?, number)

isLess(value?, number)

isMoreEqual(value?, number)

isLessEqual(value?, number)

isRange(value?, min, max)

isPositive(value?)

isNegative(value?)

isNonNegative(value?)

isNonPositive(value?)

isEven(value?)

isOdd(value?)

isTrue(value?)

isFalse(value?)

isRegex(value?, regex)

isExists(value?)

isLength(value?, number || ...[min, max])

isSize(value?, number || ...[min, max])

isEmpty(value?)

isHas(value?, key)

isIncludes(value1?, value2)

isIncluded(value1?, value2)

isUnique(value?)

isTimestamp(value?)

isUnixTimestamp(value?)

isUUID(value?)

isIPv4(value?)

isUrl(value?)

isEmail(value?)

isPhoneNumber(value?)

isASCII(value?)

isBase64(value?)

isBase64Url(value?)

isBase58(value?)

isJWT(value?)

Keywords

FAQs

Package last updated on 20 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc